<% content_for :title, "Liste des Incidents" %>
<%= javascript_include_tag :defaults %>



<h1>Liste des Incidents</h1>
<%=  "il y a #{@events.size} incidents" %>

<script type="text/javascript">
		jQuery(document).ready(function() {
			// Initialise Plugin
			var options = {
				additionalFilterTriggers: [jQuery('#quickfind')]
			};
			jQuery('#demotable').tableFilter();
		});
		
	</script> 

	<table id='demotable'>
		
<thead>
	<tr>
	<th>Nom salle</th>
	<th>Nom machine</th>
	<th filter-type='ddl'>Type d'incident</th>
	<th>Informations</th>
	<th filter-type='ddl'>Etat</th>
	<th>Date création</th>
	<th>Date résolution</th> 
	<th filter='false'>Actions</th>
  </tr>
</thead>

<tbody>

<% @events.each do |event| %>
  <%  # change background for event updated less than 3 minutes ago
	if 3.minutes.ago.to_formatted_s(:db) < event.date_resolution
	  tr_class = ' class="bg_orange"'
	else
	  tr_class = ''
	end
  %>
  <tr	<%= tr_class %>		>
	<td><%=h event.room_name %></td>
	<td><%=h event.computer_name %></td>	
	<td><%=h event.type_event %></td>
	<td><%=h event.event_info %></td>
	<td><% if event.state_event=="1" %><%=h "non résolu"  %> <% else %><%=h "résolu"  %> <% end %></td> 
	<td><%=h event.date_creation %></td>
	<td><% if event.state_event=="1" %><%=h "non résolu"  %> <% else %><%=h event.date_resolution %><% end %></td> 
	<td>
		<%= link_to image_tag("icons/zoom.png", :title=>"Afficher") , url_for(:controller => "events", :action => "show", :id => event.event_id)  %>
		<% if current_user %>
			<%= link_to image_tag("icons/edit.png", :title=>"Modifier") , url_for(:controller => "events", :action => "edit", :id => event.event_id) %>
			 <%= link_to image_tag("icons/delete.png", :title=>"Modifier"), { :action => "destroy", :id => event.event_id}, :confirm => "Are you sure?", :method => :delete, :form_class=> "toto" %>
		<% end %>
	</td>
	
  </tr>

<% end %>
</tbody>
</table>
<script type="text/javascript">
          jQuery("#demotable").tablePagination({});

</script> 
